package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Bumenrenyuanxinxi;
import com.ruoyi.system.service.IBumenrenyuanxinxiService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 部门人员信息表Controller
 * 
 * @author Quilan
 * @date 2023-12-04
 */
@RestController
@RequestMapping("/system/bumenrenyuanxinxi")
public class BumenrenyuanxinxiController extends BaseController
{
    @Autowired
    private IBumenrenyuanxinxiService bumenrenyuanxinxiService;

    /**
     * 查询部门人员信息表列表
     */
    @PreAuthorize("@ss.hasPermi('system:bumenrenyuanxinxi:list')")
    @GetMapping("/list")
    public TableDataInfo list(Bumenrenyuanxinxi bumenrenyuanxinxi)
    {
        startPage();
        List<Bumenrenyuanxinxi> list = bumenrenyuanxinxiService.selectBumenrenyuanxinxiList(bumenrenyuanxinxi);
        return getDataTable(list);
    }

    /**
     * 导出部门人员信息表列表
     */
    @PreAuthorize("@ss.hasPermi('system:bumenrenyuanxinxi:export')")
    @Log(title = "部门人员信息表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Bumenrenyuanxinxi bumenrenyuanxinxi)
    {
        List<Bumenrenyuanxinxi> list = bumenrenyuanxinxiService.selectBumenrenyuanxinxiList(bumenrenyuanxinxi);
        ExcelUtil<Bumenrenyuanxinxi> util = new ExcelUtil<Bumenrenyuanxinxi>(Bumenrenyuanxinxi.class);
        util.exportExcel(response, list, "部门人员信息表数据");
    }

    /**
     * 获取部门人员信息表详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:bumenrenyuanxinxi:query')")
    @GetMapping(value = "/{organizationName}")
    public AjaxResult getInfo(@PathVariable("organizationName") String organizationName)
    {
        return success(bumenrenyuanxinxiService.selectBumenrenyuanxinxiByOrganizationName(organizationName));
    }

    /**
     * 新增部门人员信息表
     */
    @PreAuthorize("@ss.hasPermi('system:bumenrenyuanxinxi:add')")
    @Log(title = "部门人员信息表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Bumenrenyuanxinxi bumenrenyuanxinxi)
    {
        return toAjax(bumenrenyuanxinxiService.insertBumenrenyuanxinxi(bumenrenyuanxinxi));
    }

    /**
     * 修改部门人员信息表
     */
    @PreAuthorize("@ss.hasPermi('system:bumenrenyuanxinxi:edit')")
    @Log(title = "部门人员信息表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Bumenrenyuanxinxi bumenrenyuanxinxi)
    {
        return toAjax(bumenrenyuanxinxiService.updateBumenrenyuanxinxi(bumenrenyuanxinxi));
    }

    /**
     * 删除部门人员信息表
     */
    @PreAuthorize("@ss.hasPermi('system:bumenrenyuanxinxi:remove')")
    @Log(title = "部门人员信息表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{organizationNames}")
    public AjaxResult remove(@PathVariable String[] organizationNames)
    {
        return toAjax(bumenrenyuanxinxiService.deleteBumenrenyuanxinxiByOrganizationNames(organizationNames));
    }
}
